<?php
namespace app\index\model;
use think\Model;
use think\Db;
// 用户表模型
class Login extends Model
{

	public function login($data){
		$captcha = new \think\captcha\Captcha();//验证吗类
        if (!$captcha->check($data['code'])) {
            return 4;
        } 
		$user=Db::name('user')->where('username','=',$data['username'])->find();
		if($user){
			if($user['password'] == md5($data['password'])){
				session('username',$user['username']);
				session('uid',$user['uid']);
				return 3; //信息正确
			}else{
				return 2; //密码或用户名错误
			}
		}else{
			return 1; //用户不存在
		}
	}
	// 删除
	public function delink($id){
        if($this::destroy($id)){
            return 1;
        }else{
            return 2;
        }
    }
   











}
